<template>
  <el-form ref="form">
    <!-- <div>Array</div> -->
    <div>
      <div class="labsTitle" @click="isHidden()">
        Array[{{ index }}]<span> Data</span>
      </div>
      <div v-show="flag != 0">
        <el-form-item
          v-for="(item, i) in datakeys"
          :key="i"
          :label="item"
          class="labsStyleRaw"
        >
          <el-link
            v-show="editingRow !== i"
            :underline="false"
            type="primary"
            @dblclick.native="editingRow = i"
            ><span>{{ '"' + val[item] + '"' }}</span></el-link
          >
          <el-input
            style="width: 700px"
            @blur.native.capture="editingRow = -1"
            v-model="val[item]"
            v-show="editingRow === i"
          ></el-input>
        </el-form-item>
        <treelist :content="val.content"> </treelist>
      </div>
    </div>
  </el-form>
</template>

<script>
import treelist from "./treelist.vue";
export default {
  name: "labsList",
  props: ["val", "index", "labsData"],
  components: {
    treelist,
  },
  data() {
    return {
      contentData: [],
      flag: 0,
      show: 0,
      datakeys: [],
      editingRow: -1,
    };
  },

  created() {
    this.getcontent();

    this.getKeys();
  },

  mounted() {},
  methods: {
    //取content
    getcontent() {
      this.contentData = this.val.content;
    },
    // 取字段名
    getKeys() {
      let _this = this;
      for (let key in _this.val) {
        if (key != "content") {
          _this.datakeys.push(key);
        }
      }
    },
    //labs隐藏显示
    isHidden() {
      this.flag;
      if (this.flag === 0) {
        this.flag = 1;
      } else {
        this.flag = 0;
        this.show = 0;
      }
      console.log(this.flag);
    },
    //content隐藏显示
    isShow() {
      this.show;
      if (this.show === 0) {
        this.show = 1;
      } else {
        this.show = 0;
      }
    },
    // 点击某一行
    clickRow(idx) {
      this.$set(this.keyflag, idx, !this.keyflag[idx] && true);
    },
    //获取数据
    getData() {
      this.editingRow = 1;
    },
  },
};
</script>

<style lang="scss" scoped>
::-webkit-scrollbar {
  width: 50px;
}
.labsTitle {
  margin-left: 10px;
  height: 23px;
  font-size: 14px;
  font-family: Alibaba PuHuiTi-Bold, Alibaba PuHuiTi;
  font-weight: bold;
  color: #333333;
  line-height: 23px;
  & span {
    margin-left: 12px;
    font-size: 14px;
    font-family: Alibaba PuHuiTi-Bold, Alibaba PuHuiTi;
    font-weight: bold;
    color: #4353e4;
  }
}
.labsStyleRaw {
  margin-bottom: -5px !important;
  width: 1000px;
  display: flex;
}
.labsHeight {
  min-height: 30px;
  display: inline;
}
</style>
